<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<title>ECSHOP 管理中心 - 添加新商品 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/smfs/Public/admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="/smfs/Public/admin/css/main.css" rel="stylesheet" type="text/css" />

<link href="/smfs/Public/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="/smfs/Public/layui.js"></script>

</head>
<body>

<h1>
<span class="action-span"><a href="<?php echo U('admin/goods/goodslist');?>">商品列表</a></span>
<span class="action-span1"><a href="index.php?act=main">添加新商品</a></span>
<div style="clear:both"></div>
</h1>

<div class="tab-div">

    <!-- tab body -->
    <div id="tabbody-div">
      <form class="layui-form" method="post" action="<?php echo U('admin/goods/goodsadd');?>" enctype="multipart/form-data">
        <!-- 最大文件限制 -->
        <!-- <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> -->
        <!-- 通用信息 -->
        <table width="90%" id="general-table" align="center">
          <tr>
            <td class="label">商品名称：</td>
            <td>
                <input type="text" name="goods_name"  required  lay-verify="required" placeholder="请输入商品名称" style="height: 25px;margin-bottom: 10px;"/>
            </td>
          </tr>
          <tr>
            <td class="label">商品分类：</td>
            <td>
            <div style="width: 150px;margin-bottom: 10px;">
            <select name="cat_id"  >
              <?php foreach ($cats as $v) { ?>
              <option value="<?php echo ($v["cat_id"]); ?>"><?php echo (str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$v["lev"])); echo ($v["cat_name"]); ?></option>
              <?php } ?>
            </select>
            </div>
            </td>
          </tr>
          <tr>
            <td class="label">本店售价：</td>
            <td><input type="text" name="shop_price" required  lay-verify="required" placeholder="请输入商品单价" style="height: 25px;margin-bottom: 10px;" /> 元</td>
          </tr>
          <tr>
            <td class="label">库存数量：</td>
            <td><input type="text" name="goods_number" value="1" required  lay-verify="required" placeholder="请输入商品数量" style="height: 25px;margin-bottom: 10px;" /> 件</td>
          </tr>
          <tr>
            <td class="label">上传商品图片：</td>
            <td>
              <!-- <img id="LAY_demo_upload" src=""> -->
              <div id="yincimg"><input type="file" name="goods_img" style="height: 25px;margin-bottom: 10px;" id="goods_img"/></div>
              <input type="hidden" name="new_goods_img" id="new_goods_img" value="">
              <input type="hidden" name="new_thumb_img" id="new_thumb_img" value="">
            </td>
          </tr>
          <tr>
            <td class="label">商品描述： </td>
            <td>
            <div style="width: 400px;"><textarea class="layui-textarea" name="goods_desc" id="LAY_demo1"></textarea></div><br />
            <span class="notice-span" style="display:block"  id="noticeSellerNote">* 简单描述，尽量不要超过20字。</span></td>
          </tr>
        </table>

        <div class="button-div">
          <button lay-submit lay-filter="*" > 确定 </button>
          <input type="reset" value=" 重置 " >
        </div>
      </form>
    </div>
</div>
<!-- end goods form -->

<script type="text/javascript">
    layui.use(['form','layedit','upload'], function(){
      $ = layui.jquery;
      var layer = layui.layer
      ,layedit = layui.layedit
      ,form = layui.form();
      //layer.msg('Hello World');

  // layui.upload({
  //   url: "<?php echo U('admin/goods/good_img');?>"
  //   ,elem: '#goods_img' //指定原始元素，默认直接查找class="layui-upload-file"
  //   ,method: 'post' //上传接口的http类型
  //   ,success: function(res){
  //     if (res.code ==0) {
  //       layer.msg(res.msg,{icon:5});
  //     }else{
  //       layer.msg(res.msg,{icon:6});
  //       LAY_demo_upload.src = res.data.src;
  //       $("#yincimg").hide();
  //       $("#new_goods_img").val(res.data.ori_url);
  //       $("#new_thumb_img").val(res.data.thumb_url);
  //     };
  //   }
  // });

  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo1', {height: 100,
                tool: ['strong','italic','underline','del']
                });

    // form.on('submit(*)', function(data){
    //     data.field.goods_desc = layedit.getContent(editIndex);
    //     $.ajax({
    //         url: "<?php echo U('admin/goods/goods_add');?>",//请求地址
    //         type: "post",//请求方式
    //         dataType: "json",//返回数据类型
    //         data: data.field,//发送的参数
    //         })
    //         .done(function(response) {
    //               if(response.error==0){
    //                  layer.msg(response.info ,{icon:5});

    //               }else{
    //                  layer.msg(response.info ,{icon:6});
    //                  location.href = response.url;
    //               }
    //           })
    //         .fail(function() {
    //             alert("ajxs交互失败");
    //         })  

    //       return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    //     });  
     });
</script>
</body>
</html>